package com.yl.ydk.ui.activity

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.yl.ydk.R
import com.yl.ydk.base.BaseActivity
import com.yl.ydk.presenter.contract.HealthyMallHomeContract
import com.yl.ydk.presenter.impl.HealthyMallHomeImpl
import com.blankj.utilcode.utils.ToastUtils
import kotlinx.android.synthetic.main.activity_healthy_mall_home.*
import kotlinx.android.synthetic.main.roob_bar.*

class HealthyMallHomeActivity : BaseActivity(), View.OnClickListener, HealthyMallHomeContract.View {

    private var mPresenter = HealthyMallHomeImpl()

    override fun getLayoutId(): Int = R.layout.activity_healthy_mall_home

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun detachView() {
        mPresenter.detachView()
    }

    override fun initView() {
        tvTitle.text = "健康商城"
        rlBack.setOnClickListener(this)
        mPresenter.getGoodsList(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rlBack -> {
                finish()
            }
        }
    }

    override fun getRecyclerView(): RecyclerView = rvMall

    override fun getActivity(): HealthyMallHomeActivity  =  this

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}